package me.shurufa.utils;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Paint;

/**
 * Created by tian on 14/10/20:下午11:46.
 */
public class ImageUtils {



    public static final int WECHAT_SHARE_BITMAP_SIZE = 32 * 1000;






    public static Bitmap getWeChatShareBitmap(Bitmap image) {
        if (image == null)
            return null;
        if (image.getByteCount() < WECHAT_SHARE_BITMAP_SIZE) {
            return image;
        } else {
            Bitmap bitmap = Bitmap.createBitmap(
                    image.getWidth(), image.getHeight(), Config.ARGB_8888);
            Paint paint = new Paint();
            Canvas canvas = new Canvas(bitmap);
            canvas.drawColor(0xFFFFFFFF);
            canvas.drawBitmap(image, 0, 0, paint);
            return Bitmap.createScaledBitmap(bitmap, 100, 100, false);
        }

    }
}
